<?php
/*
	require_once("include/config.inc.php");
	
	$file = "documents/example_spreadsheet.csv";
	$fh = fopen($file, 'r');
	
	$count = 0;
	
	while ($row = fgets($fh)) {
		
		if ($count != 0) {
			$vals = explode(',', $row);
			
			if (!(empty($vals[1]) && $vals[11] != "online")) {
				#print_r($vals);
				#echo "<br/><br/>";
				$honors=0;
				if ($vals[11] == "honors") {
					$honors =1;
				}
				
				list($subject, $course_num, $section_num) = explode("-", $vals[1]);
				
				if ($subject == "CSCI") {
					$subject_id=2;
				}
				if ($subject == "CIST") {
					$subject_id=1;
				}
				
				$graduate_level=0;
				
				if ($course_num >=8000) {
					$graudate_level=1;
				}
				
				$title=$vals[2];
				#echo "|$title|<br/>";
				$hours_per_week=$vals[3];
				#echo "|$hours_per_week|<br/>";
				$instructor=$vals[10];
				#echo "|$instructor|<br/>";
				
				#echo "$instructor <br/>";
				
				if ($instructor == "???") {
					$last_name = "TBA";
					$first_name = "TBA";
				}
				elseif ($instructor == "STAFF") {
					$last_name = "STAFF";
					$first_name = "STAFF";
				}
				else {
					list ($last_name, $first_name) = explode(" ", $instructor);
				}
				
				if ($subject_id==2) {
					$query="update courses set course_subject_id=2 where course_number='$course_num' and title='$title'";
				}
				
				$result=mysql_query($query);
				
				
				#echo "<br/>$last_name, $firstname<br/>";
				
				#echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br/>";
	
				
				$max_seats = $vals[9];
				
				
				#$result = mysql_query($query);
				#$num_row = mysql_num_rows($result);
				
				/*
				
				if ($instructor != "???" or $instructor != "STAFF") {
					$query = "select id 
						  from instructors
						  where first_name='$first_name' and
						  last_name='$last_name'";
				
					$result=mysql_query($query);
					
					if (mysql_num_rows($result)==0) {
						$query="insert into instructors
								values ('', '$first_name', '$last_name')";
						if (!$result=mysql_query($query)) {
							echo mysql_error();
						}
						$instructor_id = mysql_insert_id();
					}
					else {
						$row=mysql_fetch_assoc($result);
						$instructor_id=$row['id'];
					}
					
				}
				else {
					$instructor_id=3;
				}
			
				$query = "select id 
						  from courses
						  where course_number = '$course_num' and
						  course_subject_id='$subject_id'";
						  
						  
				
				$result=mysql_query($query);
					
				if (mysql_num_rows($result)==0) {
					$query="insert into courses
							values ('', '$course_num', '$subject_id', '$title', '$hours_per_week', null, '$graduate_level')";
					if (!$result=mysql_query($query)) {
						echo mysql_error();
					}
					
					$course_id = mysql_insert_id();
				}	
				else {
					$row=mysql_fetch_assoc($result);
					$course_id=$row['id'];
				}
				
				
				$query = "insert into course_sections
						  values('', '$section_num', '1', '$instructor_id', '1', '$max_seats', '$honors')";
				
				$result=mysql_query($query);
				
				#echo mysql_error()."<br/><br/>";
				
				$course_section_id = mysql_insert_id();
				
				$query = "insert into course_section_mapping
						  values('', '$course_section_id', '$course_id' ,'1')";

				$result=mysql_query($query);
				
				
				
			}
		
		
		}
		$count++;
	}



*/

?>